import {createRouter,createWebHistory} from 'vue-router'
import Home from '@/pages/Home.vue'
import News from '@/pages/News.vue'
import About from '@/pages/About.vue'
import Detail from '@/pages/news/Detail.vue'
const router = createRouter({
    history:createWebHistory(),//路由器工作模式
    routes:[
        {
            name:'homeName',
            path:'/home',
            component:Home
        },
        {
            name:'newsName',
            path:'/news',
            component:News,
            children:[
                // {
                //     name:'xiang',
                //     path:'detail',
                //     component:Detail
                // }

                //路由props
                 {
                    name:'xiang',
                    path:'detail/:id/:title/:content?',
                    component:Detail,
                    // props的布尔值写法，作用：把收到了每一组params参数，作为props传给Detail组件
                    // props:true
                    
                    // props的函数写法，作用：把返回的对象中每一组key-value作为props传给Detail组件
                    // props(route){
                    //     return route.query
                    // }
                 }
                
            ]
        },
        {
            name:'aboutName',
            path:'/about',
            component:About
        }
    ]
    
})
export default router